<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="/WEB-INF/tld/tag.tld" prefix="tag"%>
<!DOCTYPE html>
<html>
<head>
<jsp:include page="inc/include-head.jsp" flush="true" />
<title>Logar Area Restrita</title>
</head>
<body>
	<jsp:include page="inc/include-topo.jsp" flush="true" />
	<div class="col-sm-4"></div>

	<div class="conteudo">
		<div class="col-sm-4">

			<div class="panel-group">
				<div class="panel panel-default">

					<div id="collapseOne" class="panel-collapse in active">
						<div class="centerPanel panel-body">

							<h3 class="titulo1">Cadastrar</h3>

							<form:form method="post" commandName="usuario" modelAttribute="usuario" id="form-usuario" action='restrito/usuario-form.do'>
								<div class="col-sm-12">
									<div class="form-group">
										<label for="nome">Nome</label> <form:input class="form-control" path="nome" id="nome" /> <br />
									</div>
									<div class="form-group">
										<label for="nome">E-mail</label> <form:input class="form-control" path="email" id="email" /> <br />
									</div>
									<div class="form-group">
										<label for="nome">Login</label> <form:input class="form-control" path="login" id="login" /> <br />
									</div>
									<div class="form-group">
										<label for="cidade">Senha</label>
										<form:password cssClass="form-control" path="senha" id="senha" />
										<br />
									</div>
									<div class="form-group">
										<label for="cidade">Confirmar Senha</label> <input class="form-control" name="senha" id="senha" /> <br />
									</div>
								</div>
								<div class="col-sm-12">
									<button class="btn btn-roxo" style="margin-top: 20px;" name="gravar">Gravar</button>
								</div>
							</form:form>

						</div>


					</div>


				</div>
			</div>
		</div>


	</div>
	<div class="col-sm-4"></div>
	<script type="text/javascript">
$(document).ready(function(){
    $("#form-usuario").submit(function(event){
        event.preventDefault();
        var nome = $(this).find("input[name='nome']").val();

        
        
        $.post($(this).attr("action"), $(this).serialize(), function(response){
        		
            	var responseJson = JSON.parse(decodeURIComponent(response));
            	if(responseJson.sucesso){
					console.log("sucesso");
            	}
            	alert(responseJson.mensagem);
        	}, 'text');
    	});
});
</script>

</body>
</html>